package cn.itcast.mobilebrowser.model;

import android.graphics.Bitmap;
import android.webkit.WebView;

import java.util.Objects;

/**
 * 标签页的数据类
 */
public class WebTab {
    private String title;
    private Bitmap image;
    private WebView webView;

    // 用于标识对象的id
    private int id;
    // 自增的标识id
    public static int NUM = 0;

    public WebTab(String title, Bitmap image, WebView webView) {
        this.title = title;
        this.image = image;
        this.webView = webView;
        // 自增id
        NUM++;
        this.id = NUM;
    }

    public WebTab() {
        // 自增id
        NUM++;
        this.id = NUM;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Bitmap getImage() {
        return image;
    }

    public void setImage(Bitmap image) {
        this.image = image;
    }

    public WebView getWebView() {
        return webView;
    }

    public void setWebView(WebView webView) {
        this.webView = webView;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof WebTab)) return false;
        WebTab webTab = (WebTab) o;
        return Objects.equals(title, webTab.title) &&
                Objects.equals(image, webTab.image) &&
                Objects.equals(webView, webTab.webView);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title, image, webView);
    }
}